//
//  TBRSelfDriveDetailOnOffCarCell.m
//  TBRentClient
//
//  Created by tonbright on 2018/5/18.
//  Copyright © 2018年 tonbright. All rights reserved.
//

#import "TBRSelfDriveDetailOnOffCarCell.h"
@interface TBRSelfDriveDetailOnOffCarCell()
@property (weak, nonatomic) IBOutlet UIView *view_green;
@property (weak, nonatomic) IBOutlet UIView *view_red;
@property (weak, nonatomic) IBOutlet UISwitch *switch_on;
@property (weak, nonatomic) IBOutlet UISwitch *switch_off;

@end
@implementation TBRSelfDriveDetailOnOffCarCell

- (void)awakeFromNib {
    [super awakeFromNib];
    _view_red.layer.cornerRadius = 6.5;
    _view_green.layer.cornerRadius = 6.5;
}

- (IBAction)btnClick:(UIButton *)sender {
    if ([self.delegate respondsToSelector:@selector(selfDriveAppointCellBtnClick:)]) {
        [self.delegate selfDriveAppointCellBtnClick:sender.tag];
    }
}
- (void)refreshUI {
    TBRRentAllMessageModel *allMessageModel = [TBRRentAllMessageModel shareAllMessageModel];
    _switch_on.on = allMessageModel.isGetCarFromShop;
    _switch_off.on = allMessageModel.isReBackCarToShop;
    if (allMessageModel.isGetCarFromShop) {
        _lbe_onCarPlace.text = [HelpObject isBlankString:allMessageModel.isGetCarFromShopOnPlace] ? @"请选择您的取车地点" : allMessageModel.isGetCarFromShopOnPlace;
    }else {
        _lbe_onCarPlace.text = [HelpObject isBlankString:allMessageModel.onPlace] ? @"请选择您的取车地点" : allMessageModel.onPlace;
    }
    
    _lbe_offCarPlace.text = [HelpObject isBlankString:allMessageModel.offPlace] ? @"请选择您的还车地点" : allMessageModel.offPlace;
    
    _lbe_StartDate.text = allMessageModel.startDateTime;
    _lbe_StartWeekHour.text = allMessageModel.startWeakHour;
    
    _lbe_timeDuration.text = [NSString stringWithFormat:@"%ld",[AppSetting shareAppSetting].timeDuration];
    _lbe_endDate.text = allMessageModel.endDateTime;
    _lbe_endWeekHour.text = allMessageModel.endWeakHour;
}

- (IBAction)isGetOrBackCarShop:(UISwitch *)sender {
    TBRRentAllMessageModel *allMessageModel = [TBRRentAllMessageModel shareAllMessageModel];
    if (sender.tag == 100) {
        allMessageModel.isGetCarFromShop = sender.isOn;
        allMessageModel.onPlace = @"";
        allMessageModel.isGetCarFromShopOnPlace = @"";
    }else {
        allMessageModel.isReBackCarToShop = sender.isOn;
        allMessageModel.offPlace = @"";
    }
    [self refreshUI];
}

@end
